package com.test.ch02;

/**
 * @author yuxi
 * @version 1.0
 * @date 2025/10/23
 * @Description:
 */
import java.util.Objects;

/**
 * @description 课程类
 */
public class Course {
    /**
     类型：@see Long
     注释：课程编号
     */
    private Long id;
    /**
     类型：@see String
     注释：课程名称
     */
    private String name;
    /**
     类型：@see String
     注释：课程信息
     */
    private String info;

    //全参构造器

    public Course(Long id, String name, String info) {
        this.id = id;
        this.name = name;
        this.info = info;
    }

    //空参构造器

    public Course() {
    }

    //Get、Set方法

    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getInfo() {
        return info;
    }

    public void setInfo(String info) {
        this.info = info;
    }

    //equals、hashCode方法

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        Course course = (Course) o;
        return Objects.equals(id, course.id) && Objects.equals(name, course.name) && Objects.equals(info, course.info);
    }

    @Override
    public int hashCode() {
        return Objects.hash(id, name, info);
    }

    //toString方法

    @Override
    public String toString() {
        return "Course{" +
                "id=" + id +
                ", name='" + name + '\'' +
                ", info='" + info + '\'' +
                '}';
    }
}